package bdqn.t09.service.impl;

import bdqn.t09.dao.AsAccountdetailMapper;
import bdqn.t09.pojo.AsAccountdetail;
import bdqn.t09.service.AsAccountdetailService;
import bdqn.t09.util.Pageinfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class AsAccountdetailServiceImpl implements AsAccountdetailService{

    @Resource
    private AsAccountdetailMapper asAccountdetailMapper;


    @Override
    public int deleteByPrimaryKey(Long id) {
        return asAccountdetailMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(AsAccountdetail record) {
        return asAccountdetailMapper.insert(record);
    }

    @Override
    public int insertSelective(AsAccountdetail record) {
        return asAccountdetailMapper.insertSelective(record);
    }

    @Override
    public AsAccountdetail selectByPrimaryKey(Long id) {
        return asAccountdetailMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(AsAccountdetail record) {
        return asAccountdetailMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(AsAccountdetail record) {
        return asAccountdetailMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<AsAccountdetail> asAccountdetailList1() {
        return asAccountdetailMapper.asAccountdetailList1();
    }
    @Override
    public List<AsAccountdetail> asAccountdetailList2(String detailDateTime1,String detailDateTime2) {
        return asAccountdetailMapper.asAccountdetailList2(detailDateTime1,detailDateTime2);
    }
    @Override
    public List<AsAccountdetail> asAccountdetailList3(String detailDateTime1,String detailDateTime2) {
        return asAccountdetailMapper.asAccountdetailList3(detailDateTime1,detailDateTime2);
    }


    @Override
    public Pageinfo selectAsAccountdetailMapper(Integer pageindex, Integer row) {
        // 调用工具类里的分页类
        Pageinfo pageinfo = new Pageinfo();
        // 更新工具类的当前下标
        pageinfo.setCurrIndex(pageindex);
        // 更新工具类的行
        pageinfo.setRows(row);
        // 拿到总行数
        int count = asAccountdetailMapper.count();
        // 更新工具类的总行数
        pageinfo.setCount(count);
        Map map=new HashMap();
        // 当前页
        int offset = (pageindex-1)*row;
        map.put("offset",offset);
        map.put("rows",row);
        // 调用asAccountdetailMapper下的分页查询
        List<AsAccountdetail> sysMenus = asAccountdetailMapper.selectAsAccountdetailMapper(map);
        pageinfo.setList(sysMenus);
        return  pageinfo;
    }

    @Override
    public Pageinfo selectBy(Integer pageindex, Integer row, Integer id, String beginDate, String endDate) {
        System.out.println(pageindex+":"+row+":"+id+":"+beginDate+":"+endDate+":");
        Pageinfo pageinfo=new Pageinfo();
        pageinfo.setCurrIndex(pageindex);
        pageinfo.setRows(row);
        int count = asAccountdetailMapper.countBy(id,beginDate,endDate);
        System.out.println(count);
        pageinfo.setCount(count);
        Map map=new HashMap();
        int offset = (pageindex-1)*row;
        map.put("offset",offset);
        map.put("rows",row);
        map.put("id",id);
        map.put("beginDate",beginDate);
        map.put("endDate",endDate);
        List<AsAccountdetail> sysMenus = asAccountdetailMapper.selectAsAccountdetailMapperBy(map);
        pageinfo.setList(sysMenus);
        return  pageinfo;
    }
}
